<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSystemModelsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('system_models', function (Blueprint $table) {
            $table->increments('id')->comment('ID');
            $table->integer('parent_id')->nullable()->default(0)->comment('父级ID');
            $table->string('name', 50)->nullable()->comment('字段名称');
            $table->string('alias', 50)->nullable()->comment('字段别名');
            $table->string('slug', 50)->nullable()->comment('字段标识');
            $table->string('type')->nullable()->default('input')->comment('字段类型');
            $table->string('desc')->nullable()->comment('字段描述');
            $table->string('options')->nullable()->comment('选项');
            $table->string('value', 5000)->nullable()->comment('默认值');
            $table->text('validation_rules')->nullable()->comment('表单验证规则
');
            $table->string('filter_rules')->nullable()->comment('列表筛选规则');
            $table->integer('order')->default(0)->comment('排序');
            $table->boolean('is_virtual')->nullable()->default(false)->comment('是否是虚拟字段');
            $table->boolean('search_hide')->nullable()->default(false)->comment('搜索栏是否隐藏');
            $table->boolean('list_hide')->nullable()->default(false)->comment('列表页是否隐藏');
            $table->boolean('form_hide')->nullable()->default(false)->comment('表单页是否隐藏');
            $table->boolean('detail_hide')->nullable()->default(false)->comment('详情页是否隐藏');
            $table->boolean('form_disabled')->nullable()->default(false)->comment('表单输入框是否禁用');
            $table->unsignedInteger('list_width')->nullable()->default('150')->comment('列表页宽度');
            $table->string('list_fixed', 50)->nullable()->comment('列表页固定');
            $table->dateTime('created_at')->nullable()->comment('创建时间');
            $table->dateTime('updated_at')->nullable()->comment('更新时间');
            $table->softDeletes()->comment('删除时间');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('system_models');
    }
}
